///////////////////////////////////////////////////////////////////////////////
// Plugin architecture example                                               //
//                                                                           //
// This code serves as an example to the plugin architecture discussed in    //
// the article and can be freely used                                        //
///////////////////////////////////////////////////////////////////////////////
#ifndef KERNEL_H
#define KERNEL_H

#include <plugin.h>
#include <processorManager.h>
#include <modelManager.h>
#include <viewManager.h>

#include <string>
#include <map>

class Kernel {
  public:
	__declspec(dllexport) ProcessorManager &getProcessorManager() { return m_ProcessorManager; }
	__declspec(dllexport) ModelManager &getModelManager() { return m_ModelManager; }
	__declspec(dllexport) ViewManager &getViewManager() { return m_ViewManager; }

    /// Loads a plugin
    __declspec(dllexport) void loadPlugin(const std::string &sFilename) {
      if(m_LoadedPlugins.find(sFilename) == m_LoadedPlugins.end())
        m_LoadedPlugins.insert(PluginMap::value_type(
          sFilename,
          Plugin(sFilename)
        )).first->second.registerPlugin(*this);
    }
    
  private:
    /// Map of plugins by their associated file names
    typedef std::map<std::string, Plugin> PluginMap;
    
    PluginMap		m_LoadedPlugins;	///< All plugins currently loaded
    ProcessorManager	m_ProcessorManager;		///< The processor
	ModelManager		m_ModelManager;
	ViewManager		m_ViewManager;
};


#endif //KERNEL_H